<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\Db;
/**
 * Description of ServerController
 *
 * @author Administrator
 */
class ServerController extends AdminBaseController {
    public function index(){
        $data = Db::name('server_cfg')->paginate(40);
        $this->assign('server',$data->items());
        $this->assign('page',$data->render());
        return $this->fetch();
    }
    
    public function edit(){
        $serverid = $this->request->param('id');
        if($serverid){
            $this->assign('id',$serverid);
            $data = Db::name('server_cfg')->find($serverid);
            $this->assign($data);
        }
        return $this->fetch();
    }
    
    public function doPost(){
        $data = $this->request->param();
        if($data['id']){
            Db::name('server_cfg')->strict(false)->update($data);
        }else{
            Db::name('server_cfg')->strict(false)->insert($data);
        }
        $this->success('保存成功');
    }
}
